using UnityEngine;
using System.Collections;

[RequireComponent (typeof (Animator))]
public class AnimateCharacter : MonoBehaviour {
	public Transform model;
	public Animator animator;
	public RigidbodyFPSController controller;

	// Use this for initialization
	void Start () {
		animator = GetComponent<Animator>();
	}
	
	// Update is called once per frame
	void Update () {
		Vector3 forward = model.transform.forward;
		forward.y = 0f;
		transform.localRotation = Quaternion.LookRotation(forward, controller.transform.up);
		
		if (animator != null) {
			animator.SetFloat("PlayerSpeed", controller.speed);
		}
	}
}